package com.lmc.health;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;

import com.github.jdsjlzx.interfaces.OnItemClickListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.lmc.R;
import com.lmc.adapter.MemberAdapter;
import com.lmc.entity.Members;
import com.qxzn.app.bean.FamilyMemberBean;
import com.qxzn.app.page.BaseActivity;

import org.greenrobot.eventbus.EventBus;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 健康模块里的家庭成员列表
 */
public class MembersActivity extends BaseActivity {
    LRecyclerView membersRecycler;

    private ArrayList<FamilyMemberBean.MemberBean> members_list;

    @Override
    protected int initLayout() {
        return R.layout.lmc_activity_members;
    }

    @Override
    protected void initView() {
        membersRecycler = findViewById(R.id.members_recycle_view);
    }

    @Override
    protected void iniTitleBar() {
        tv_title.setText("全部家庭成员");
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

        members_list = (ArrayList<FamilyMemberBean.MemberBean>) getIntent().getSerializableExtra("members_list");

        LRecyclerViewAdapter adapter = new LRecyclerViewAdapter(new MemberAdapter(members_list, this));
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                // todo 点击
                EventBus.getDefault().post(members_list.get(position));
                finish();
            }
        });
        membersRecycler.setAdapter(adapter);
        membersRecycler.setPullRefreshEnabled(false);
        membersRecycler.setLoadMoreEnabled(false);
    }

    public static void start(Context context, ArrayList<FamilyMemberBean.MemberBean> members_list) {
        Intent intent = new Intent(context, MembersActivity.class);
        intent.putExtra("members_list", members_list);
        context.startActivity(intent);
    }


}
